Skip to content

feat(core): theme service refactor (#DS-3003) - #1856

Merged
NikGurev merged 15 commits into
mainfrom
feat/DS-3003
Aug 13, 2026
Merged

feat(core): theme service refactor (#DS-3003)#1856
NikGurev merged 15 commits into
mainfrom
feat/DS-3003

Conversation

@NikGurev

@NikGurev NikGurev commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors ThemeService (DS-3003) into a signal-based KbqThemeService: a closed mode: 'auto' | 'light' | 'dark' signal resolved against the OS color scheme and a registered themes() set, replacing index/name-based selection with colorScheme-driven resolution. ThemeService is kept as a deprecated facade for backward compatibility.

Notable changes

  • added KbqThemeService — signals mode, themes, currentTheme, colorScheme; toggle() flips light/dark; persists via a swappable KBQ_THEME_STORE (KbqThemeLocalStorageStore by default, KbqThemeCookieStore for live SSR)
  • added KbqThemeConfig (name, className, required colorScheme) replacing KbqTheme for registered themes, plus KbqDefaultThemes/KbqThemeSelector/KbqThemeNames for the built-in light/dark set
  • added kbqThemeProvider(config) / KBQ_THEME_CONFIG for DI-based setup (custom themes, initial mode, storage key)
  • kept ThemeService, KbqTheme, current/setTheme()/getTheme() as deprecated shims backed by KbqThemeService
  • updated internal consumers (navbar, dev apps) to the new API; refreshed theme.service.spec.ts and core.api.md

What should reviewers focus on

  • Whether the deprecated back-compat surface is worth keeping vs. a cleaner break
  • mode/colorScheme as the final shape, replacing the earlier selection/autoLight/autoDark draft

@NikGurev
NikGurev requested a review from artembelik August 7, 2026 10:18
@NikGurev NikGurev self-assigned this Aug 7, 2026
@NikGurev NikGurev added the enhancement New feature or request label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit c59aa1e):

https://koobiq-next--prs-1856-jmotwjcq.web.app

(expires Sun, 16 Aug 2026 07:12:11 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c

@NikGurev
NikGurev marked this pull request as ready for review August 7, 2026 10:42
@NikGurev
NikGurev requested a review from lskramarov as a code owner August 7, 2026 10:42
@artembelik
artembelik requested a balanced review from Copilot August 10, 2026 08:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the core ThemeService (DS-3003) into a signal-based KbqThemeService. It introduces a built-in auto mode that follows the OS color scheme via matchMedia, adds out-of-the-box mode persistence through a swappable KBQ_THEME_STORE (default KbqThemeLocalStorageStore), and DI-based configuration via kbqThemeProvider()/KBQ_THEME_CONFIG. Backward compatibility is preserved: ThemeService remains as a deprecated alias, and current, KbqTheme.selected, setTheme()/getTheme() still work. Consumers across the docs app and docs-examples are migrated to the signal API, and the docs navbar's hand-rolled matchMedia/localStorage wiring is removed.

Changes:

  • New signal-based KbqThemeService (mode, resolvedMode, currentTheme, themes) with setAuto()/toggle()/setMode(), internal OS-scheme handling, and DI config (kbqThemeProvider, KBQ_THEME_CONFIG, KBQ_THEME_STORE, KbqThemeLocalStorageStore).
  • Deprecated back-compat surface kept (ThemeService alias, current, selected, setTheme/getTheme); public API snapshot approved.
  • Migrated all consumers (navbar, welcome, docsearch, tokens-overview, theme-toggle, 7 docs-examples) to the signal API; added theme.service.spec.ts and migration docs.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/components/core/services/theme.service.ts New KbqThemeService, config/store tokens, deprecated ThemeService alias.
packages/components/core/services/theme.service.spec.ts New unit tests for auto/mode/custom themes/persistence/SSR/deprecated shims.
tools/public_api_guard/components/core.api.md Approved public API changes for the new/renamed symbols.
apps/docs/src/app/config.ts Wires kbqThemeProvider({ storageKey: 'docs_theme' }) (see comment — format mismatch).
apps/docs/src/app/components/navbar/navbar.component.ts / navbar.template.html Removes hand-rolled matchMedia/storage; drives dropdown off mode()/setMode().
apps/docs/src/app/components/welcome/welcome.component.ts Uses resolvedMode() computed instead of current observable.
apps/docs/src/app/components/docsearch/docsearch.directive.ts Uses toObservable(resolvedMode) for the search theme.
apps/docs/src/app/components/design-tokens-viewers/tokens-overview.ts / .spec.ts Recalculates via effect on resolvedMode(); test mocks matchMedia.
packages/components-dev/theme-toggle.ts Dev toggle rewired to resolvedMode()/setMode() via effect.
packages/docs-examples/** (7 files) Switched currentTheme to resolvedMode() computed; dropped unused rxjs imports.
docs/guides/migration.en.md / migration.ru.md Adds a "13. Theme service review" migration section.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/docs/src/app/config.ts
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts
Comment thread packages/components/core/services/theme.service.ts Outdated
@NikGurev
NikGurev marked this pull request as draft August 11, 2026 08:35
@NikGurev
NikGurev marked this pull request as ready for review August 11, 2026 15:24
@NikGurev
NikGurev requested a review from artembelik August 11, 2026 15:41
Comment thread packages/components/core/services/theme.service.ts
Comment thread packages/components/core/services/theme.service.ts
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts Outdated
Comment thread packages/components/core/services/theme.service.ts
Comment thread packages/components/core/services/theme.service.ts Outdated
@NikGurev
NikGurev merged commit 5875144 into main Aug 13, 2026
13 checks passed
@NikGurev
NikGurev deleted the feat/DS-3003 branch August 13, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants